#include "animation.h"
#include <lampe/xml/IXMLFactoryEnvironment.h>
#include "irrxml.h"
#include <lampe/xml/IXmlNode.h>
#include <lampe/animation/IAnimation.h>
#include <lampe/animation/IAnimationDB.h>
#include <ISceneManager.h>
namespace lampe{
namespace xml{
class AnimationFactoryRecord:public IIrrXmlNode{
public:
	AnimationFactoryRecord(irr::IrrlichtDevice*d):IIrrXmlNode(d){}
	virtual lampe::xml::TagResult tagHandlerBefor(lampe::xml::IXMLFactoryEnvironment*environment,lampe::xml::IXmlNode*node){
		if (!lampe::animation::getDefaultAnimationDB())
			return lampe::xml::STOP;
		if (node->getAttString("name","")=="")
			return lampe::xml::STOP;
		lampe::animation::IAnimation*anim=lampe::animation::createSkinnedAnimation(node->getAttString("name",""),getDevice()->getSceneManager());
		node->setTag(anim);
		lampe::animation::getDefaultAnimationDB()->addAnimation(anim);
		return lampe::xml::NEXT;
	}
	
	virtual LAMPE_VECTOR_VENDOR<String> getProcessedTags(){
		LAMPE_VECTOR_VENDOR<String> res;
		res.push_back("animation");
		return res;
	};
};
}//namespace xml
}//namespace lampe
void regAnimation(lampe::xml::IXMLFactoryEnvironment*environment,irr::IrrlichtDevice*d){
	lampe::xml::AnimationFactoryRecord*temp=new lampe::xml::AnimationFactoryRecord(d);
	environment->registerHandler(temp);
	temp->drop();
}
